import request  from "@/utils/request";
import requestMock from "@/utils/requestMock";

// 请问首页的三级分类列表
export const requestCategoryList = () =>(
  request.get('/api/product/getBaseCategoryList')
)

//请求banner数据
export const requestBannerList = () => {
  return requestMock.get("/banner");
};

//请求floor的数据
export const requestFloorList = () => {
  return requestMock.get("/floor");
};

// 请求搜索列表
export const reqSearchList = (params) =>(
  request.post('/api/list' , params)
)

// 根据skuId获取搜索详情
export const reqDetailInfo = (skuId) => (
  request.get(`/api/item/${skuId}`)
)

//新增购物车 或者 修改购物车某个商品的数量 的请求
export const requestAddOrUpdataNumCart = ( skuId, skuNum ) => (
  request.post(`/api/cart/addToCart/${skuId}/${skuNum}`)
)


//获取购物车列表
export const requestShopCart = () => {
  return request.get(`/api/cart/cartList`);
};

// 删除购物车数据
export const deleteCartList = skuId => (
  request.delete(`/api/cart/deleteCart/${skuId}`)
)

// 修改单个状态
export const changeChecked = (skuId, isChecked)=> (
  request.get(`/api/cart/checkCart/${skuId}/${isChecked}`)
)

// 批量选中购物车
export const changeAllChecked = (isChecked,skuIdList) => (
  request.post(`/api/cart/batchCheckCart/${isChecked}`,skuIdList)
)


// 删除所有选中的商品
export const reqDeleteAllCart = (skuIdList) =>(
  request.delete(`/api/cart/batchDeleteCart`,{
    data: skuIdList
  })
)



// 获取验证码
export const reqVerifyCode = (phone) => (
  request.get(`/api/user/passport/sendCode/${phone}`)
)

//注册请求
export const requestRegister = (registerInfo) => (
  request.post(`/api/user/passport/register`, registerInfo)
)

//登录请求
export const requestLogin = (userInfo) => {
  return request.post("/api/user/passport/login", userInfo);
};

//登录以后获取用户信息
export const requestUserInfo = () => {
  return request.get("/api/user/passport/auth/getUserInfo");
};


//退出登录
export const requestLogout = () => {
  return request.get("/api/user/passport/logout");
};

// 请求用户地址的mock数据
export const reqAddress = () =>(
  requestMock.get('/address')
)

//交易页数据获取
export const requestTradeInfo = () => {
  return request.get("/api/order/auth/trade");
};

//提交订单
export const requestAddTrade = (tradeNo, tradeInfo) => {
  return request.post(
    `/api/order/auth/submitOrder?tradeNo=${tradeNo}`,
    tradeInfo
  );
};

//根据订单号获取订单详细信息
export const requestPayDetail = (orderId) => {
  return request.get(`/api/payment/weixin/createNative/${orderId}`);
};

//查看某个订单编号的支付状态
export const requestPayStatus = (orderId) => {
  return request.get(`/api/payment/weixin/queryPayStatus/${orderId}`);
};

//查看订单列表
export const requestOrderList = ({ page, limit }) => {
  return request.get(`/api/order/auth/${page}/${limit}`);
};


